package yogiro.dao;

import java.sql.SQLException;
import java.util.ArrayList;
import java.util.HashMap;

import org.springframework.orm.ibatis.SqlMapClientTemplate;

import yogiro.to.NoticeCommentTO;

public class NoticeCommentDAO {
private SqlMapClientTemplate sqlMap;
	
	public NoticeCommentDAO(){}

	public NoticeCommentDAO(SqlMapClientTemplate sqlMap){
		this.sqlMap = sqlMap;
	}
	
	public int sequence() throws SQLException{
		return (int)sqlMap.queryForObject("commentSequence");
	}
	//삽입 메소드
	public Object insertComment(NoticeCommentTO cto)throws SQLException{
		return sqlMap.insert("insertNoticeComment",cto);
	}
	//전체조회
	public ArrayList<NoticeCommentTO> selectAllComment(int noticeNo)throws SQLException{
		System.out.println((ArrayList<NoticeCommentTO>)sqlMap.queryForList("selectAllComment",noticeNo));
		return (ArrayList<NoticeCommentTO>)sqlMap.queryForList("selectAllComment",noticeNo);
	}
	
	
	//no로 조회한 값 update
	public Object updateCommentReply(int refamily, int restep)throws SQLException{
		HashMap map = new HashMap();
		map.put("refamily", refamily);
		map.put("restep", restep);
		return sqlMap.update("updateCommentReply",map);
	}
}
